package com.example.footballsystem.controller;

import com.example.footballsystem.entity.Book;
import com.example.footballsystem.entity.Field;
import com.example.footballsystem.entity.FieldPosition;
import com.example.footballsystem.service.BookService;
import com.example.footballsystem.service.FieldService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/Field")
@CrossOrigin(origins = "*")
public class FiledController {
    @Autowired
    FieldService fieldService;
    //获取全部预定信息
    @GetMapping("/getAllField")
    public ResponseEntity<List<Field>> getAllFiled(){
        //log.info(fieldService.getAllField().toString());
        return ResponseEntity.ok().body(fieldService.getAllField());
    }
    @GetMapping("/searchField")
    public ResponseEntity<List<Field>> searchField(String info){
        return ResponseEntity.ok().body(fieldService.getField(info));
    }
    //获取位置
    @GetMapping("/getPosition")
    public ResponseEntity<FieldPosition> getPosition(int id){
        return ResponseEntity.ok().body(fieldService.getPosition(id));
    }
    @PostMapping("/addField")
    public ResponseEntity<Boolean> addField(@RequestBody Field field){
        return ResponseEntity.ok().body(fieldService.addField(field));
    }
    @PostMapping("/deleteField")
    public ResponseEntity<Boolean> deleteField(@RequestBody Field field){
        return ResponseEntity.ok().body(fieldService.deleteField(field));
    }
}
